package com.fulihui.wgj.mq.kafka.producer;

import com.fulihui.starter.kafka.sdk.KafkaProducerSdk;
import com.fulihui.wgj.facade.msg.EventMsg;
import com.fulihui.wgj.facade.msg.MassMsg;
import com.fulihui.wgj.facade.msg.TemplateMsg;
import com.fulihui.wgj.facade.msg.UserMsg;
import com.fulihui.wgj.facade.msg.Wx48HMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import static com.fulihui.common.constants.TopicConstants.AUTO_TEMPLATE_MSG;
import static com.fulihui.common.constants.TopicConstants.EVENT_NOTIFY;
import static com.fulihui.common.constants.TopicConstants.MASS_MSG;
import static com.fulihui.common.constants.TopicConstants.PRE_AUTH;
import static com.fulihui.common.constants.TopicConstants.PULL_USER_OPENID_LIST;
import static com.fulihui.common.constants.TopicConstants.TEMPLATE_MSG;
import static com.fulihui.common.constants.TopicConstants.WX_48H_MSG;

/**
 * kafka生产者
 *
 * @author wang_wx
 * @date 2018-06-21
 */
@Component
public class KafkaProducer extends AbstractProducer {

    @Autowired
    public void setKafkaProducerSdk(KafkaProducerSdk kafkaProducerSdk) {
        super.kafkaProducerSdk = kafkaProducerSdk;
    }

    /**
     * 推送预授权相关事件消息到队列
     *
     * @param eventMsg
     */
    public void sendPreAuthEvent(EventMsg eventMsg) {
        send(PRE_AUTH, eventMsg);
    }

    /**
     * 推送事件消息到队列
     *
     * @param eventMsg
     */
    public void sendEventNotify(EventMsg eventMsg) {
        send(EVENT_NOTIFY, eventMsg);
    }

    /**
     * 推送拉取用户openid列表到消息队列
     *
     * @param message
     */
    public void sendPullUserOpenidsMsg(UserMsg message) {
        send(PULL_USER_OPENID_LIST, message);
    }

    /**
     * 48小时消息发送
     *
     * @param message
     */
    public void sendWx48hMsg(Wx48HMsg message) {
        send(WX_48H_MSG, message);
    }

    /**
     * 模板消息发送
     *
     * @param message
     */
    public void sendTemplateMsg(TemplateMsg message) {
        send(TEMPLATE_MSG, message);
    }

    /**
     * 图文群发消息发送
     *
     * @param message
     */
    public void sendMassMsg(MassMsg message) {
        send(MASS_MSG, message);
    }

    /**
     * 模板消息发送-自动化任务
     *
     * @param message
     */
    public void sendAutoTemplateMsg(TemplateMsg message) {
        send(AUTO_TEMPLATE_MSG, message);
    }

}
